package br.com.wssa.smmb.entidades;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
import org.hibernate.validator.constraints.NotEmpty;

/**
 * @author ssilva
 *
 */
@Entity
@Table(name = "grupo")
public class Grupo implements Serializable {

	/**
	 *  
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@Generated(GenerationTime.INSERT)
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true)
	protected long id;

	@NotNull
	@NotEmpty
	@Column(name = "nome", nullable = false, length = 128)
	private String nome;

	@ManyToMany(fetch=FetchType.EAGER)
	@JoinColumn(name = "role_id", nullable = false)
	private Set<Role> roles;

    @OneToMany(fetch=FetchType.LAZY)
    @JoinColumn(name="grupo_id")
	private Set<Usuario> usuarios;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public Set<Usuario> getUsuarios() {
		return usuarios;
	}

	public void setUsuarios(Set<Usuario> usuarios) {
		this.usuarios = usuarios;
	}
}